package com.stox.ui.javafx.charting.model.cursor;

import javafx.geometry.Point2D;
import javafx.scene.Cursor;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;

import com.stox.ui.javafx.charting.widget.Chart;

public class CrosshairCursor extends AbstractStoxChartingCursor {

	@Override
	public void paint(Chart<?> chart) {
		Canvas canvas = chart.getCanvas();

		if(!Cursor.NONE.equals(canvas.getCursor()))
			canvas.setCursor(Cursor.NONE);
		
		GraphicsContext graphicsContext = canvas.getGraphicsContext2D();
		graphicsContext.setLineWidth(0.5);
		graphicsContext.setStroke(Color.DARKGRAY);
		Point2D point = canvas.sceneToLocal(getSceneX(), getSceneY());
		graphicsContext.strokeLine(canvas.getLayoutX(), point.getY(),canvas.getLayoutX() + canvas.getWidth(), point.getY());
		graphicsContext.strokeLine(point.getX(), canvas.getLayoutY(),point.getX(), canvas.getLayoutY() + canvas.getHeight());
	}
	
}
